package com.XinYun.Library.modules.Register.Dao.Impl;

import cn.hutool.db.StatementUtil;
import com.XinYun.Library.modules.Register.Dao.UserDao;
import com.XinYun.Library.modules.Register.Entity.User;
import com.XinYun.Library.utils.SqlUtils.DruidUtil;
import com.XinYun.Library.utils.SqlUtils.ResultSetHandlers.ResultSetHandler;
import com.XinYun.Library.utils.SqlUtils.SqlExecutor;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class UserDaoImpl implements UserDao {
    private static Connection connection;
    AllDaoImpl allDao = new AllDaoImpl();
    User user = new User();

    /**
     * 判断内部邀请码是否正确
     * @param code
     * @return
     */
    @Override
    public boolean isCode(String code) {
        String rightCode = user.getCode();
        if (rightCode.equals(code)){
            return true;
        }
        return false;
    }

    /**
     * 判断是否验证成功
     * @param username
     * @param direction
     * @param date
     * @return
     * @throws Exception
     */
    @Override
    public boolean isVerify(String username, String direction, String date) throws Exception {
        String inDirection = allDao.queryDirection(username);
        String inDate = allDao.queryDate(username);
        int uid = allDao.queryUid(username);
        if (uid!=0){
            if (date.equals(inDate)){
                if (direction.equals(inDirection)){
                    return true;
                }
            }
        }
        return false;
    }
}
